# t_countries_election_years.R
# Outputs: Table of elections in appendix
# Dependencies: master_elec.csv

library(dplyr)
library(xtable)

setwd('')

e <- read.csv('master_elec.csv', stringsAsFactors = F) %>% tbl_df() %>%
  arrange(country_name, election_year)

dtab <-
  e %>% filter(election_type == 'parliament') %>% group_by(country_name) %>%
  summarise(elec_years = paste(election_year, collapse = ', '))

names(dtab) <- c('Country', 'Elections')

xtab <- xtable(dtab)

print(xtab, file = 'tables/t_countries_election_years.tex',
      floating = F, only.contents = T, booktabs = T,
      include.rownames = F,
      size = 'small')
